﻿using System.Collections;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Genesis.Infrastructure.Web.Extensions
{

    public static class HtmlHelperExtensions
    {

        public static void RenderPartials(this HtmlHelper helper, string partialViewName, IEnumerable models)
        {

            foreach (object model in models)
                helper.RenderPartial(partialViewName, model);

        }

        public static void RenderPartials(this HtmlHelper helper, string partialViewName, IEnumerable models, ViewDataDictionary viewData)
        {

            foreach (object model in models)
                helper.RenderPartial(partialViewName, model, viewData);

        }

        public static MvcHtmlString SubmitButton(this HtmlHelper helper, string buttonText)
        {

            TagBuilder builder = new TagBuilder("input");
            
            builder.Attributes.Add("type", "submit");
            builder.Attributes.Add("value", buttonText);

            return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));

        }

    }

}